from LL import Node

def minicommon(l1, l2, l3):
	INF = float("inf")
	while l1!=INF and l2!=INF and l3!=INF:
		if l1.v==l2.v and l2.v==l3.v:
			return l1.v #or anything else
		elif l1.v<=l2.v and l1.v<=l3.v:
			l1 = l1.nx
		elif l2.v<=l1.v and l2.v<=l3.v:
			l2 = l2.nx
		else:
			l3 = l3.nx
	return -1

l1 = Node(1, Node(2, Node(3, Node(float("inf"), None))))
l2 = Node(-1, Node(1.5, Node(2.99, Node(3, Node(float("inf"), None)))))
l3 = Node(1, Node(2, Node(3, Node(4, Node(float("inf"), None)))))
print minicommon(l1, l2, l3)
